package com.agileboot.domain.bot.botQuestion.query;

import cn.hutool.core.util.StrUtil;
import com.agileboot.common.core.page.AbstractPageQuery;
import com.agileboot.domain.bot.botQuestion.db.BotQuestionEntity;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * BotQuestion 查询参数封装类
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class BotQuestionQuery extends AbstractPageQuery<BotQuestionEntity> {

    private String question;
    private String createUser;

    @Override
    public QueryWrapper<BotQuestionEntity> addQueryCondition() {
        QueryWrapper<BotQuestionEntity> wrapper = new QueryWrapper<>();
        wrapper
                .like(StrUtil.isNotEmpty(question), "question", question)
                .eq(StrUtil.isNotEmpty(createUser), "create_user", createUser);

        // 设置默认排序字段
        if (StrUtil.isEmpty(this.getOrderColumn())) {
            this.setOrderColumn("create_time");
        }

        // 设置范围时间字段
        this.setTimeRangeColumn("create_time");

        return wrapper;
    }
}
